package com.gitee.wsl.common.chart.render.foreground.border

import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint

import android.graphics.RectF

/**
 * 标注框
 */

class SideBox(var baseRectF: RectF,
              val boxColor:Int= Color.parseColor("#99129823"),
              val boxLineWidth:Float = 5f,//标注框线宽
              val decorationColor:Int = Color.parseColor("#5DA9FF"),
              val decorationLineWidth:Float = 10f,//装饰线宽度
              var showDragWidth:Boolean = false,
              val dragWidth:Float = 30f,//拖拽区域宽度
              val decorationType:SideBoxStyle = SideBoxStyle.NONE) {

    val boxPaint: Paint by lazy {
        Paint().apply {
            color = boxColor
            style = Paint.Style.STROKE
            strokeWidth = boxLineWidth
        }
    }

    val decorationPaint: Paint by lazy {
        Paint().apply {
            color = boxColor
            style = Paint.Style.STROKE
            strokeWidth = decorationLineWidth
            this.isAntiAlias=true
        }
    }

    val broadsidePaint: Paint by lazy {
        Paint().apply {
            color = Color.parseColor("#99345212")
            strokeWidth = dragWidth
        }
    }

    val cornerPaint: Paint by lazy {
        Paint().apply {
            color = boxColor
            strokeWidth = dragWidth
        }
    }


    fun init(baseSize:RectF){
        baseRectF = baseSize
        when(decorationType){
            SideBoxStyle.OUT_RECT->{}
            SideBoxStyle.RECT->{}
            SideBoxStyle.CIRCLE->{}
            else -> {}
        }
    }

    fun render(canvas: Canvas){
        canvas.drawRect(baseRectF, boxPaint);
        //边框装饰
        drawDecoration(canvas, decorationType);
        //开发测试使用
       /* if (showDragWidth) {
            canvas.drawRect(leftRectF, broadsidePaint);
            canvas.drawRect(topRectF, broadsidePaint);
            canvas.drawRect(rightRectF, broadsidePaint);
            canvas.drawRect(bottomRectF, broadsidePaint);

            canvas.drawRect(leftTopRectF, cornerPaint);
            canvas.drawRect(rightTopRectF, cornerPaint);
            canvas.drawRect(leftBottomRectF, cornerPaint);
            canvas.drawRect(rightBottomRectF, cornerPaint);
        }*/
    }

    fun drawDecoration(canvas: Canvas,type:SideBoxStyle){

    }



}

enum class SideBoxStyle{
    NONE,RECT,CIRCLE,OUT_RECT
}